package com.yuezhu.com_volley;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Response;
import com.android.volley.toolbox.JsonObjectRequest;

import org.json.JSONObject;

/**
 * 封装PostRequest
 */
public class OkPostRequest extends JsonObjectRequest {
	public OkPostRequest(String url, JSONObject jsonRequest,
						 Response.Listener<JSONObject> listener,
						 Response.ErrorListener errorListener) {
		super(Method.GET, url, jsonRequest, listener, errorListener);
		this.setRetryPolicy(new DefaultRetryPolicy(10 * 1000, 0, 1.0f));
	}
	//  
	public static String setEncrypt(String str){
		String password=str;//要加密或者解密的字符串
        char[]array=password.toCharArray();//获取字符数组  
        for(int i=0;i<array.length;i++)//遍历字符数组  
        {  
            array[i]=(char)(array[i] ^ 20140908);//对每个数组元素进行异或运算，异或的值可以自己选择  
        }  
        System.out.println("加密或者解密结果如下："+str);
        System.out.println(new String(array));//输出加密或者解密结果
    return new String(array);
    }
	/*
	 * @Override public Map<String, String> getHeaders() throws AuthFailureError
	 * { HashMap<String, String> header = new HashMap<String, String>();
	 * header.put("Accept", "application/json"); header.put("Content-type",
	 * "application/json"); return header; }
	 */

	/**
	 * 获取RequestId
	 * 
	 * @return
	 */
	public String getRequestId() {

		return String.valueOf(this.hashCode());
	}
}
